<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<title>elementUI级联菜单演示</title>
</head>
<body>
<div id="app">
	<el-cascader :options="options"></el-cascader>
</div>
<script>
	let data=[
		'中国,湖南,株洲,荷塘区,大学',
		'中国,天庭,南瞻部州,社会大学,牛逼工程系'
	];
	let newData=data.map(o=>o.split(',').reverse());
	// newData=newData.map(x=>x.map(y=>({value:y,label:y,children[]})))
	newData=newData.map(x=>x.map(y=>({value:y,label:y,children:[]})));
	let showData=[];
	newData.forEach(x=>x.forEach((y,i,arr)=>{
		// i ? y.children=undefined:null
		i ? {}:y.children=undefined;
		i<arr.length-1 ? arr[i+1].children.push(y):showData.push(y);
	}))
	
	console.log(showData)
	
let app=new Vue({
	el:"#app",
	data:{
		options:showData
		
	},
		
});
</script>
</body>
<html>
